<%-- 
    Document   : manageOrder
    Created on : Oct 8, 2012, 6:54:16 PM
    Author     : Nhan
--%>

<%@page import="com.Order"%>
<%@page import="com.Checker"%>
<%@page import="com.User"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Manage Order Page</title>
        
    </head>
    <body>
        <table border="1" cellspacing="0">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Order ID</th>
                    <th>Date Placed</th>
                    <th>Username</th>
                    <th>Total Payment</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                <%
                    ArrayList<Order> allOrders = Checker.getAllOrders();
                    int index = 0;
                    if (allOrders.size() != 0) {
                        for (Order order : allOrders) {
                            index++;
                            String orderID = order.getOrderID();
                            String dateTimePlaced = order.getTimePlaced();
                            String status = order.getStatus();
                            float totalPayment = order.getTotlPayment();
                            String username = order.getUsername();
                %>

                <tr>
                    <td><%= index %></td>
                    <td><%= orderID %></td>
                    <td><%= dateTimePlaced%></td>
                    <td><%= username  %></td>
                    <td><%= totalPayment %></td>
                    <td>
                        <form action="../centralUnit" method="GET">
                            <select name="orderStatus">
                                <option <%= status.equalsIgnoreCase("pending") ? "selected='selected'" : "" %> >PENDING</option>
                                <option <%= status.equalsIgnoreCase("processing") ? "selected='selected'" : "" %> >PROCESSING</option>
                                <option <%= status.equalsIgnoreCase("completed") ? "selected='selected'" : "" %> >COMPLETED</option>
                            </select>
                            <input type="submit" name="action" value="updateOrderStatus" size="" />
                        </form>
                    </td>
                    
                </tr>
                <% }
                           } else {%>

                <tr><td colspan="6"><h3>There are no account to manage!</h3></tr>

                <% }

                %>
            </tbody>
        </table>
    </body>
</html>
